Skip to content

Fix empty list handling for tool filters in session methods#487

Open
Halcyonhal9 wants to merge 2 commits intogithub:mainfrom
Halcyonhal9:main
Open

Fix empty list handling for tool filters in session methods#487
Halcyonhal9 wants to merge 2 commits intogithub:mainfrom
Halcyonhal9:main

Conversation

@Halcyonhal9
Copy link

Fix null checks for available_tools and excluded_tools in create_session and resume_session

Both create_session and resume_session use truthy checks for the available_tools and config options:
if available_tools:
if excluded_tools:

For available_tools this silently drops empty lists ([]), which prevents callers from explicitly clearing the default 14 built-in CLI tools to make toolless calls.

Changes

python/copilot/client.py: Change available_tools and excluded_tools in create_session and resume_session to
if available_tools is not None:
if excluded_tools is not None:

Test results

pytest: 111 passed, 5 skipped
ruff check: all checks passed

Ben Appleby added 2 commits February 16, 2026 15:54
…t being able to set a null list, the default 14 tools that the cli ships with are present. Sometimes you need toolless calls. Same pattern exists on the excluded_tools variable. From a quick look, there are a lot of incorrect null checks that should be tighterned up. I don't know what the functional impact is, so sticking with the case that is causing a known bug.
@Halcyonhal9 Halcyonhal9 requested a review from a team as a code owner February 17, 2026 00:14
Copilot AI review requested due to automatic review settings February 17, 2026 00:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Python SDK session creation/resume payload construction so callers can explicitly pass empty tool filter lists (e.g., available_tools: []) without them being dropped by truthy checks, enabling fully “toolless” sessions when desired.

Changes:

  • Update create_session() to treat available_tools / excluded_tools as “provided” when they are not None (including empty lists).
  • Update resume_session() with the same is not None handling for tool filters.

Comment on lines 466 to 471
available_tools = cfg.get("available_tools")
if available_tools:
if available_tools is not None:
payload["availableTools"] = available_tools
excluded_tools = cfg.get("excluded_tools")
if excluded_tools:
if excluded_tools is not None:
payload["excludedTools"] = excluded_tools
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes the empty-list case for available_tools/excluded_tools, but there isn’t a regression test that asserts an explicit empty list is preserved and results in a toolless request. Consider adding an E2E test case (similar to test_should_create_a_session_with_availableTools) that calls create_session({"available_tools": []}) and verifies the recorded request contains no tools.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines 632 to 638
available_tools = cfg.get("available_tools")
if available_tools:
if available_tools is not None:
payload["availableTools"] = available_tools

excluded_tools = cfg.get("excluded_tools")
if excluded_tools:
if excluded_tools is not None:
payload["excludedTools"] = excluded_tools
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resume_session now correctly forwards empty tool filter lists, but current tests appear to cover only create_session tool filters. Add a regression test that resumes a session with available_tools: [] (or excluded_tools: []) and asserts the subsequent request has no tools, to prevent this from regressing again.

Copilot generated this review using guidance from repository custom instructions.
@Halcyonhal9
Copy link
Author

@copilot open a new pull request to apply changes based on the comments in this thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant